package com.yyj.config;



import com.yyj.result.Result;
import com.yyj.result.ResultEnum;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestController
@RestControllerAdvice
@Order(Ordered.HIGHEST_PRECEDENCE)
public class BusinessAdvice {

    @ExceptionHandler(value = Exception.class)
    public Result handle(Exception ex) {
//        ex.printStackTrace();
        Result response = new Result();
        response.setCode(ResultEnum.FAIL.getCode());
        response.setMsg(ex.getMessage());
        return response;
    }



}
